<?php  
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2002-2005 Frédéric Descamps <lefred@tiscali.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
?>

        <CENTER>
        <H3>
<?php echo _("Rechercher un livre"); ?>
	    </H3>
        <FORM action=admin.php METHOD=POST>
        <TABLE BORDER=0>
        <TR>
        <TD>
	<?php echo _("Titre"); ?>
	:</TD><TD><INPUT TYPE="text" NAME="liv_nom" size=15" ></TD>        
        </TABLE><BR>
        <INPUT TYPE="hidden" NAME="user" value="<?php echo $user; ?>">
        <INPUT TYPE="hidden" NAME="action" value="<?php echo $action; ?>">
        <INPUT TYPE="hidden" NAME="type" value="<?php echo $type; ?>">
        <INPUT TYPE="hidden" NAME="sw" value="1">
        <INPUT TYPE="hidden" NAME="id" value="<?php echo $id; ?>">        
        <input type="Submit" value="
	<?php echo _("Rechercher"); ?>
	">
        </FORM>
        <HR>
        <FORM action=admin.php METHOD=POST>
        <TABLE BORDER=0>
        <TR>
        <TD>
	<?php echo _("ISBN"); ?>
	:</TD><TD><INPUT TYPE="text" NAME="liv_ISBN" size=15" ></TD>        
        </TABLE><BR>
        <INPUT TYPE="hidden" NAME="user" value="<?php echo $user; ?>">
        <INPUT TYPE="hidden" NAME="action" value="<?php echo $action; ?>">
        <INPUT TYPE="hidden" NAME="type" value="<?php echo $type; ?>">
        <INPUT TYPE="hidden" NAME="sw" value="1">
        <INPUT TYPE="hidden" NAME="id" value="<?php echo $id; ?>">        
        <input type="Submit" value="<?php echo  _("Rechercher"); ?>">
        </FORM>
        </CENTER><HR>
        <?php
  if($_POST['liv_ISBN']){$rech ="ISBN like '%" . return_isbn($_POST['liv_ISBN']) . "%'"; }
  if($_POST['liv_nom']){$rech ="nom like '%" . $_POST['liv_nom'] . "%'"; }
  if($rech)
  {
  $requete = "select * from livres where " . $rech ." and del = 0  order by nom";
  put_log(1,$requete,$user);
  if(!($resultat = biblio_db_query($requete)))
  { print "PROBLEME : " .biblio_db_error(); }
  else 
  {
                echo "<CENTER><H3>";
		echo _("Modifier un livre");
		echo "</H3>";                
                echo "<TABLE><TR><th>";
		echo _("Titre");
		echo "</th><th>";
		echo _("Auteur");
		echo "</th><th>";
		echo _("Genre");
		echo "</th><th>";
		echo _("ISBN");
		echo "</th><th>";
		echo _("Action");
		echo "</th>";
                while ($row = biblio_db_fetch_array($resultat)) 
	        {      
                        $liv_id = $row['id'];           
                        $liv_nom =  $row['nom'];                                
                        $liv_auteur =  $row['auteur'];     
                        $liv_genre_ID =  $row['genre_ID'];
                        $liv_local_ID =  $row['location_ID'];	
                        $liv_etat_ID =  $row['etat_ID'];
                        $liv_ISBN =  $row['ISBN'];   
                        $liv_ed = $row['edition'];   
                        $liv_date = $row['date_ed'];
                        $liv_col = $row['collection'];  
                        $liv_temp = $row['temp']; 
                        $liv_noout = $row['noout']; 
			$liv_resume = $row['resume'];
			$liv_motsclefs = $row['motsclefs'];
                        $requete = "select * from genres where id=$liv_genre_ID";
                        if($resultat2 = biblio_db_query($requete))
                        while ($row2 = biblio_db_fetch_array($resultat2)) 
	                {       
	                  $genre = $row2['genre'];
	                }
	                switch ($action)
	                {
	                    case mod : $str_a ="<IMG SRC=\"images/wh_r_arr.gif\" ALT=\"". _("changer"). "\" border=0>"; break;
	                    case del : $str_a =_("effacer"); break;
	                }
                        echo "<TR><TD>$liv_nom</TD><TD>$liv_auteur</TD><TD>$genre</TD><TD>$liv_ISBN</TD><TD ALIGN=RIGHT><A href=\"admin.php?user=$user&action=$action&type=livre&id=$liv_id\">$str_a</A></TD>";            
                }
                echo "</TABLE></CENTER>";
  }
  }      
?>
